<!--
 * @Description: 
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2023-06-28 14:33:06
 * @LastEditTime: 2023-07-10 17:11:16
 * @FilePath: \cscec-pms-admin\src\views\construction\constructionSchedule\components\AdjustRecord.vue
-->
<template>
  <BaseModal 
    :visible="visible"
    title="历史调整信息"
    :width="'90%'"
    destroy-on-close
    @cancel="handleModalCancel"
  >
    <a-table
      :columns="columns"
      :data-source="tableData"
      bordered
      :pagination="false"
      :scroll="row.nodeType === 0 ? false : {
        x: 3840
      }"
      :loading="loading"
    >
      <template 
        slot="directResPerList"
        slot-scope="text"
      >
        {{ text.map(el=>el.label).join(',') }}
      </template>
      <template 
        slot="switch"
        slot-scope="text"
      >
        <a-switch
          :checked="text"
          checked-children="是"
          un-checked-children="否"
          disabled
        />
      </template>
    </a-table>
    <template slot="footer">
      <a-button @click="handleModalCancel" :disabled="loading">
        关闭
      </a-button>
    </template>
  </BaseModal>
</template>
<script>
import BaseModal from '@/components/BaseModal'
import { columns10, columns11 } from '../model.js'
import constructionSchedule from '@/api/construction/constructionSchedule'
export default {
  name: 'AdjustRecord',
  props: {
    // 隐藏显示
    visible: {
      type: Boolean,
      require: true
    },
    // 行数据
    row: {
      type: Object,
      require: () => {}
    }
  },
  components: {
    BaseModal
  },
  computed: {
    // 表头
    columns() {
      return this.row.nodeType === 0 ? columns11 : columns10
    }
  },
  data() {
    return {
      // 表格数据
      tableData: [],
      // 表格加载
      loading: false
    }
  },
  watch:{
    visible:{
      handler(val){
        if(val){
          this.getData()
        }
      }
    }
  },
  methods: {
    /**
     * @description: 获取数据
     * @return {void}
     */    
    getData(){
      this.loading = true
      constructionSchedule.queryHistoryAdjustDetail({
        nodeId: this.row?.id,
        nodeType: this.row?.nodeType,
        projectId: this.$route.query.projectId
      }).then(res=>{
        if(res.code === 200){
          this.tableData = res.data
        }
      }).finally(()=>{
        this.loading = false
      })
    },
    /**
     * @description: 关闭模态框
     * @return {void}
     */
    handleModalCancel() {
      this.$emit('update:visible', false)
    }
  }
}
</script>
<style lang="less" scoped>
</style>
